package com.neuedu.service.impl;

import com.neuedu.dao.UserInfoDao;
import com.neuedu.model.UserInfo;
import com.neuedu.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    private UserInfoDao userInfoDao;

    @Override
    public boolean addUserInfo(UserInfo userInfo) {
        int rows = userInfoDao.insert(userInfo);
        return rows > 0;
    }

    @Override
    public UserInfo queryUserInfoByUid(Integer uid) {
        return userInfoDao.selectOne(new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<UserInfo>().eq("uid", uid));
    }

    @Override
    public boolean updateUserInfo(UserInfo userInfo) {
        int rows = userInfoDao.updateById(userInfo);
        return rows > 0;
    }

    @Override
    public boolean deleteUserInfo(Integer infoId) {
        int rows = userInfoDao.deleteById(infoId);
        return rows > 0;
    }

    @Override
    public List<UserInfo> queryAllUserInfo() {
        return userInfoDao.selectList(null);
    }
}